<?
    defined('_JEXEC') or die('Restricted access'); 
?>
<form action="index.php" method="post" name="adminForm">
    <fieldset id="filter-bar">
		<div class="filter-select fltrt">
			<select name="filter_state" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php echo JText::_('JOPTION_SELECT_PUBLISHED');?></option>
				<?php echo JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true);?>
			</select>

			<select name="filter_category_id" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php echo JText::_('JOPTION_SELECT_CATEGORY');?></option>
				<?php echo JHtml::_('select.options', JHtml::_('category.options', 'com_coupons'), 'value', 'text', $this->state->get('filter.category_id'));?>
			</select>
		</div>
	</fieldset>
	<div class="clr"> </div>
    <table class="adminlist">
    <thead>
        <tr>
            <th width="20">
                <input type="checkbox" name="toggle" value="" onclick="checkAll(<? echo count( $this->items ); ?>);" />
            </th>
            <th width="5">
                <? echo JText::_( 'ID' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_PRODUCT_NAME_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'JSTATUS' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_CATEGORY_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_OWNER_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_PRODUCT_PRICE_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_DISCOUNT_PERCENT_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_START_SELLING_DATE_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_END_SELLING_DATE_LABEL' ); ?>
            </th>
            <th>
                <? echo JText::_( 'COM_COUPONS_TARGET_LABEL' ); ?>
            </th>
        </tr>            
    </thead>
    <?
    $k = 0;
    for ($i=0, $n=count( $this->items ); $i < $n; $i++)
    {
        $row = $this->items[$i];
        $editLink = JRoute::_( 'index.php?option=com_coupons&view=coupon&layout=edit&id='.$row->id);
        $userLink = JRoute::_('index.php?option=com_users&view=user&layout=edit&id='.$row->userId);
        ?>
        <tr class="<? echo "row$k"; ?>">
            <td>
                <? echo JHTML::_('grid.id', $i, $row->id ); ?>
            </td>
            <td>
                <? echo $row->id; ?>
            </td>
            <td>
                <a href="<? echo $editLink; ?>"><? echo $row->productName; ?></a>
            </td>
            <td>
                <?php echo JHtml::_('jgrid.published', $row->state, $i, 'coupons.'); ?>
            </td>
            <td>
                <? echo $this->getCategory($row->catid); ?>
            </td>
            <td>
                <a href="<? echo $userLink; ?>"><? echo $this->getUser($row->userId); ?></a>
            </td>
            <td>
                <? echo $row->productPrice." ".$row->currency; ?>
            </td>
            <td>
                <? echo $row->discountPercent; ?>
            </td>
            <td>
                <? echo $row->startSellingDate; ?>
            </td>
            <td>
                <? echo $row->endSellingDate; ?>
            </td>
            <td>
                <? echo $this->getShop($row->target); ?>
            </td>
        </tr>
        <?
        $k = 1 - $k;
    }
    ?>
    <tfoot>
        <tr>
            <td colspan="11">
                   <?php echo $this->pagination->getListFooter(); ?>
            </td>
        </tr>
    </tfoot>
    </table>

<input type="hidden" name="option" value="com_coupons" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
</form>